<?php

class User_Form_User extends Zend_Form {

    public function init() {


        $this->setName('form_user');
        $this->setMethod('post');


        $nombre = new Zend_Form_Element_Text('nombre');
        $nombre->setLabel('Nombre')
                ->setRequired(true)
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addFilter('StringToLower')
                ->addValidator('NotEmpty', true, array('messages' => 'Ingrese su nombre'));


        $app = new Zend_Form_Element_Text('apellidos');
        $app->setLabel('Apellidos')
                ->setRequired(true)
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addFilter('StringToLower')
                ->addValidator('NotEmpty', true, array('messages' => 'Ingrese su Apellido'));


        $email = new Zend_Form_Element_Text('email');
        $email->setLabel('Email')
                ->setRequired(true)
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addFilter('StringToLower')
                ->addValidator('EmailAddress')
                ->addErrorMessage('Ingrese una dirección válida de E-mail');


        $tel = new Zend_Form_Element_Text('telefono');
        $tel->setLabel('telefono')
                ->setRequired(true)
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addFilter('StringToLower')
                ->addValidator('NotEmpty', true, array('messages' => 'Ingrese su Telefono'));

        // username
        $username = new Zend_Form_Element_Text('username');
        $username->setLabel('Nombre de Usuario')
                ->setRequired(true)
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addFilter('StringToLower')
                ->addValidator('NotEmpty', true, array('messages' => 'Ingrese su nombre de usuario'));


        // password
        $password = new Zend_Form_Element_Password('password');
        $password->setLabel('Contraseña')
                ->setRequired(true)
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addValidator('NotEmpty', true, array('messages' => 'Ingrese su contraseña'));


        $grupo = new Zend_Form_Element_Select('idgroup');
        $grupo->setLabel('Grupo')
                ->setRequired(true)
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addMultiOptions(array(
                    "" => "-- Seleccione --"
                ))
                ->addValidator('NotEmpty', true, array('messages' => 'Seleccione el grupo'));

        $type = new Zend_Form_Element_Radio('type');
        $type->setRequired(true)
                ->setLabel('Tipo de usuario')
                ->setMultiOptions(array('CLIENT' => 'Cliente', 'DEPARTAMENT' => 'Departamento'))
                ->addValidator('NotEmpty', true, array('messages' => 'Seleccione un tipo'));


        $c_d = new Zend_Form_Element_Select('client_departament');
        $c_d->setLabel('Cliente o Departamento')
                ->setRequired(true)
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addMultiOptions(array(
                    "" => "-- Seleccione --"
                ))
                ->addValidator('NotEmpty', true, array('messages' => 'Seleccione'));

        $estado = new Zend_Form_Element_Checkbox('estado');
        $estado->setLabel('Estado')
                ->setRequired(true)
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addValidator('NotEmpty', true, array('messages' => 'Ingrese su contraseña'));

        // submit
        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel('Ingresar');

        $fin = new Zend_Form_Element_Submit('finalizar');
        $fin->setLabel('Finalizar');
        // add elements
        $this->addElements(array($nombre, $app, $email, $tel, $username, $password, $grupo, $type, $c_d, $estado, $submit, $fin));
    }

}